
        Promise.allSettled2=function(promises){
            return new Promise((resolve,reject)=>{
                if(!Array.isArray(promises))return reject(new TypeError('Argument is not iterable'))
                promises.length===0&&resolve(promises)
                let count=0,results=[]
                promises.forEach((p,index)=>{
                    Promise.resolve(p).then(res=>{
                        count++
                        results[index]={status: 'fulfilled', value:res}
                        count===promises.length&&resolve(results)
                    },error=>{
                        results[index]={status: 'rejected', reason:error}
                        count++
                        count===promises.length&&resolve(results)

                    })
                })
            
            })
        }
        const p=new Promise((resolve,reject)=>{
    // resolve('哈哈')
  
    // resolve('哈哈')
//   throw 'error2'
    reject('呜呜')
})
const p2=new Promise((resolve,reject)=>{
    resolve(2)
})


Promise.allSettled2([p,p2]).then(res=>{console.log(res)},error=>{
    console.log(error,'error');
})
   